home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / func / comment.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  2.0 KB  |  89 lines

  1. /*
  2.  * comment.c -- functions handle comment window         -Brian Tierney, LBL
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include "ui.h"
  7. #include "display.h"
  8. #include "common.h"
  9. #include "log.h"
  10. #include "reg.h"
  11. #include "comment_ui.h"
  12.  
  13. /****************************************************************/
  14. cmtfile_init()
  15. {
  16.     int       cmtfile_save();
  17.  
  18.     setrtype(NOREG);
  19.     reg_setdom(NONE);
  20.  
  21.     lab_info("Enter comments in the comment window", 1);
  22.     lab_info("Hit <eval> when finished", 2);
  23.  
  24.     cmtfile_load();
  25.  
  26.     xv_set(comment_win->comm_win, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
  27.     xv_set(comment_win->comm_win, XV_SHOW, TRUE, FRAME_CLOSED, FALSE, NULL);
  28.  
  29.     return 0;
  30. }
  31.  
  32. /****************************************************************/
  33. cmtfile_reset()
  34. {
  35. #ifdef DEBUG
  36.     printf("comment reset \n");
  37. #endif
  38.  
  39.     cmtfile_save();
  40.  
  41.     /* close comment window */
  42.     xv_set(comment_win->comm_win, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  43.     xv_set(comment_win->comm_win, XV_SHOW, FALSE, NULL);
  44. }
  45.  
  46. /****************************************************************/
  47. cmtfile_clear()
  48. {
  49. #ifdef DEBUG
  50.     printf("comment clear \n");
  51. #endif
  52.  
  53.     textsw_erase(comment_win->textpane1, 0, TEXTSW_INFINITY);
  54. }
  55.  
  56. /****************************************************************/
  57.  
  58. cmtfile_load()
  59. {
  60.     textsw_delete(comment_win->textpane1, 0, TEXTSW_INFINITY);
  61.  
  62.     xv_set(comment_win->textpane1, TEXTSW_INSERTION_POINT, 0, NULL);
  63.     textsw_insert(comment_win->textpane1, orig_img->comment,
  64.           strlen(orig_img->comment));
  65. }
  66.  
  67. /****************************************************************/
  68. cmtfile_save()
  69. {
  70.     char     *comment_buf;
  71.     int       buf_size;
  72.  
  73.     buf_size = (int) xv_get(comment_win->textpane1, TEXTSW_LENGTH, NULL);
  74. #ifdef DEBUG
  75.     printf(" in cmtfile_save. \n");
  76.     printf(" textsw buffer size will be: %d \n", buf_size);
  77. #endif
  78.  
  79.     comment_buf = calloc(buf_size + 1, 1);
  80.  
  81.     xv_get(comment_win->textpane1, TEXTSW_CONTENTS, 0,
  82.        comment_buf, buf_size, NULL);
  83.     comment_buf[buf_size] = '\0';
  84.  
  85.     orig_img->comment = comment_buf;
  86.  
  87.     return 0;
  88. }
  89.